<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http:www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<include file="./Home/Tpl/Admin/Common/cssjs.html" />
</head>
<body>
<style type="text/css">
	html{_overflow-y:scroll}
</style>
<link href="{$Config.siteurl}statics/js/swfupload/swfupload.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" type="text/javascript" src="{$Config.siteurl}statics/js/swfupload/swfupload.js"></script> 
<script language="JavaScript" type="text/javascript" src="{$Config.siteurl}statics/js/swfupload/fileprogress.js"></script> 
<script language="JavaScript" type="text/javascript" src="{$Config.siteurl}statics/js/swfupload/handlers.js"></script> 
<script type="text/javascript">
{$initupload}
</script>
<div class="pad-10">
<div class="col-tab">
  <ul class="tabBut cu-li">
    <li id="tab_swf_1" {$tab_status} onClick="SwapTab('swf','on','',5,1);">上传附件</li>
    <li id="tab_swf_2" onClick="SwapTab('swf','on','',5,2);">网络文件</li>
    <li id="tab_swf_3" onClick="SwapTab('swf','on','',5,3);set_iframe('album_list','{:U("Attachments/album_load",array("args"=>$_GET['args']))}');">图库</li>
    <if condition="$att_not_used neq ''">
      <li id="tab_swf_5" class="on icon" onClick="SwapTab('swf','on','',5,5);">未处理文件</li>
    </if>
  </ul>
  <div id="div_swf_1" class="content pad-10 {$div_status}">
    <div>
      <div class="addnew" id="addnew"> <span id="buttonPlaceHolder"></span> </div>
      <input type="button" id="btupload" value="开始上传" onClick="swfu.startUpload();" />
      <div id="nameTip" class="onShow">最多上传<font color="red"> {$file_upload_limit}</font> 个附件,单文件最大 <font color="red">{$file_size_limit} KB</font></div>
      <div class="bk3"></div>
      <div class="lh24">支持 <font style="font-family: Arial, Helvetica, sans-serif">{$file_types}</font> 格式。</div>
      <input type="checkbox" id="watermark_enable" value="1"  onclick="change_params()">
      是否添加水印 </div>
    <div class="bk10"></div>
    <fieldset class="blue pad-10" id="swfupload">
      <legend>列表</legend>
      <ul class="attachment-list"  id="fsUploadProgress">
      </ul>
    </fieldset>
  </div>
  <div id="div_swf_2" class="contentList pad-10 hidden">
    <div class="bk10"></div>
    请输入网络地址
    <div class="bk3"></div>
    <input type="text" name="info[filename]" class="input-text" value=""  style="width:350px;"  onblur="addonlinefile(this)">
    <div class="bk10"></div>
  </div>
  <div id="div_swf_3" class="contentList pad-10 hidden">
    <ul class="attachment-list">
      <iframe name="album-list" src="#" frameborder="false" scrolling="no" style="overflow-x:hidden;border:none" width="100%" height="345" allowtransparency="true" id="album_list"></iframe>
    </ul>
  </div>
  
  <if condition="$att_not_used neq ''">
    <div id="div_swf_5" class="contentList pad-10">
      <div class="explain-col">上次上传未处理的附件，如使用请点击选择。</div>
      <ul class="attachment-list" id="album">
      
        <volist name="att" id="vo">
        <li>
          <div class="img-wrap"> <a onClick="javascript:album_cancel(this,'{$vo.aid}','{$vo.src}')" href="javascript:;" class="off"  title="{$vo.filename}">
            <div class="icon"></div>
            <img width="{$vo.width}"  path="{$vo.src}" src="{$vo.fileimg}" title="{$vo.filename}"></a> </div>
        </li>
        </volist>
        
      </ul>
    </div>
  </if>
  
  <div id="att-status" class="hidden"></div>
  <div id="att-status-del" class="hidden"></div>
  <div id="att-name" class="hidden"></div>
  <!-- swf --> 
</div>
</body>
<script type="text/javascript">
if ($.browser.mozilla) {
	window.onload=function(){
	  if (location.href.indexOf("&rand=")<0) {
			location.href=location.href+"&rand="+Math.random();
		}
	}
}
function imgWrap(obj){
	$(obj).hasClass('on') ? $(obj).removeClass("on") : $(obj).addClass("on");
}

function SwapTab(name,cls_show,cls_hide,cnt,cur) {
    for(i=1;i<=cnt;i++){
		if(i==cur){
			 $('#div_'+name+'_'+i).show();
			 $('#tab_'+name+'_'+i).addClass(cls_show);
			 $('#tab_'+name+'_'+i).removeClass(cls_hide);
		}else{
			 $('#div_'+name+'_'+i).hide();
			 $('#tab_'+name+'_'+i).removeClass(cls_show);
			 $('#tab_'+name+'_'+i).addClass(cls_hide);
		}
	}
}

function addonlinefile(obj) {
	var strs = $(obj).val() ? '|'+ $(obj).val() :'';
	$('#att-status').html(strs);
}

function change_params(){
	if($('#watermark_enable').attr('checked')) {
		swfu.addPostParam('watermark_enable', '1');
	} else {
		swfu.removePostParam('watermark_enable');
	}
}
function set_iframe(id,src){
	$("#"+id).attr("src",src); 
}
function album_cancel(obj,id,source){
	var src = $(obj).children("img").attr("path");
	var filename = $(obj).attr('title');
	if($(obj).hasClass('on')){
		$(obj).removeClass("on");
		var imgstr = $("#att-status").html();
		var length = $("a[class='on']").children("img").length;
		var strs = filenames = '';
		$.get('index.php?a=swfupload_json_del&m=Attachments&g=Attachment&aid='+id+'&src='+source+'&filename='+filename);
		for(var i=0;i<length;i++){
			strs += '|'+$("a[class='on']").children("img").eq(i).attr('path');
			filenames += '|'+$("a[class='on']").children("img").eq(i).attr('title');
		}
		$('#att-status').html(strs);
		$('#att-status').html(filenames);
	} else {
		var num = $('#att-status').html().split('|').length;
		var file_upload_limit = '{$file_upload_limit}';
		if(num > file_upload_limit) {alert('不能选择超过'+file_upload_limit+'个附件'); return false;}
		$(obj).addClass("on");
		$.get('index.php?a=swfupload_json&m=Attachments&g=Attachment&aid='+id+'&src='+source+'&filename='+filename);
		$('#att-status').append('|'+src);
		$('#att-name').append('|'+filename);
	}
}
</script>
</body>
</html>